#include"department.h"
#include"employee.h"
#include<string.h>
using namespace MC;
using namespace std;
Department:: Department(){}
Department::Department(vector<Employee> v,const char* strName,int id)
{

	strcpy(m_strName,strName);
	m_nid=id;
	
	m_vecEmps=v;
	
	
}

Department::Department(const Department& that)
{
	m_nid=that.m_nid;
	strcpy(m_strName,that.m_strName);
	
	m_vecEmps=that.m_vecEmps;
	
	
}

bool Department::deleteEmp(int id)
{
	for (unsigned int i = 0; i < m_vecEmps.size(); ++i)
	{
		if(m_vecEmps.at(i).m_nid==id)
		{
			vector<Employee>::iterator p=m_vecEmps.begin();
			m_vecEmps.erase(p+i);
			return true;
		}
	}
	return false;
}
void Department::listEmp(void)
{
	for(unsigned int i=0;i<m_vecEmps.size();i++)
	{
		//v.push_back(m_vecEmps.at(i));
		cout << m_vecEmps.at(i);
	}
}
bool Department::modifyEmp(int id,const Employee& em)
{
	for(unsigned int i=0;i<m_vecEmps.size();i++)
	{
		if(m_vecEmps.at(i).m_nid==id)
		{
			m_vecEmps.at(i)=em;
		}
		return true;
	}
	return false;
}
Department::~Department()
{
	//delete m_vecEmps;
}
namespace MC
{
	ostream& operator<<(ostream& out,Employee& m)
	{
		 cout<<"id:"<<m.m_nid<<" "<<"name:"<<m.m_strName<<endl;
		 cout<<"sex:"<<m.m_bGender<<" "<<"age:"<<m.m_nAge<<endl;
		 return out;
	}
}
